//校验规则
export const rule = {
    require: {
        //输入框校验规则-必输
        input: (message: string | undefined = undefined) => [{ required: true, message: `请输入${message ? message : "字段"}`, trigger: "blur" }],
        //下拉框校验规则-必选
        select: (message: string | undefined = undefined) => [{ required: true, message: `请选择${message ? message : "字段"}`, trigger: "blur" }],
    },
    //输入框校验规则-长度限制
    leng: (min: number, max: number) => [{ min: min, max: max, message: `请输入${min}~${max}个字符`, trigger: ["blur", "change"] }],
    //输入框校验规则-正则表达式
    inputReg: (reg: RegExp, message: string) => [{ pattern: reg, message: message, trigger: "blur" }],
    //输入框校验规则-邮箱
    email: (message: string | undefined = undefined) => [
        { required: true, message: `请输入${message ? message : "字段"}`, trigger: "blur" },
        { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] },
    ],
    //输入框校验规则-手机号
    phone: (message: string | undefined = undefined) => [
        { required: true, message: `请输入${message ? message : "字段"}`, trigger: "blur" },
        { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号", trigger: ["blur", "change"] },
    ],
};
